#include <stdio.h>
#include <set>
using namespace std;

struct Section
{
	int begin;
	mutable int end;
	bool operator<(const Section& rhs) const
	{
		return begin < rhs.begin;
	}
};

int main()
{
	int l, t;
	scanf ("%d %d", &l, &t);

	set<Section> ss;
	while (t--)
	{
		Section s;
		scanf ("%d %d", &s.begin, &s.end);
		ss.insert(s);
	}

	set<Section>::iterator it = ss.begin();
	set<Section>::iterator it2 = ss.begin();
	it2++;
	while (it2 != ss.end())
	{
		if (it2->begin <= it->end)
		{
			if (it2->end > it->end)
				it->end = it2->end;

			ss.erase(it2);
			it2 = it;
			it2++;
		}
		else
		{
			it++;
			it2++;
		}
	}

	int amount = 0;
	for (set<Section>::iterator it = ss.begin(); it != ss.end(); it++)
	{
		amount += it->end - it->begin + 1;
	}

	printf ("%d\n", l - amount + 1);
	return 0;
}